/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.entities.Payment;
import model.entities.PaymentType;

/**
 *
 * @author Hieu.Nguyen
 */
public class PaymentTypeDAO {
    private static PaymentTypeDAO paymentTypeDAO;

    public static PaymentTypeDAO getInstance() {
        if (paymentTypeDAO == null) {
            paymentTypeDAO = new PaymentTypeDAO();
        }
        return paymentTypeDAO;
    }
    
     public List<PaymentType> getPaymentType(boolean isActived) {
        List<PaymentType> listPaymentType = new ArrayList<PaymentType>();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblPaymentType";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                PaymentType r = new PaymentType();
                r.setPaymentTypeID(rs.getInt("PaymentTypeID"));
                r.setPaymentType(rs.getString("PaymentType"));
                r.setPaymentTypeDesc(rs.getBoolean("PaymentTypeDesc")); 
                listPaymentType.add(r);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listPaymentType;
    }
    
}
